package com.xm;

import java.util.ArrayList;
import java.util.Collections;

/**
 * @Author：xm
 * @Project：runoob
 * @Date：2024/7/14 13:36
 */

public class ArrayList01 {
    public static void main(String[] args) {
        ArrayList<String> arrayList = new ArrayList<>();
        arrayList.add("hello");
        arrayList.add("xm");
        arrayList.add("hhh");
        System.out.println("arrayList = " + arrayList);
        System.out.println(arrayList.size());
        System.out.println(arrayList.get(1));

        arrayList.set(2, "666");
        System.out.println("arrayList = " + arrayList);

        arrayList.remove(2);
        System.out.println("arrayList = " + arrayList);

        for (int i = 0; i < arrayList.size(); i++) {
            System.out.println(arrayList.get(i));
        }

        for (String s : arrayList) {
            System.out.println(s);
        }

        ArrayList<Integer> integers = new ArrayList<Integer>();
        integers.add(10);
        integers.add(20);
        integers.add(30);
        for (int i : integers) {
            System.out.println(i);
        }

        Collections.sort(arrayList);
        System.out.println("arrayList = " + arrayList);


    }
}
